<%@page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" %>
<%@ page import="entity.Commodity"%>
<%@ page import="service.CommodityLogic"%>

<html>
<head>
    <style type="text/css">
        hr{
            border-color: #72A3D0;
        }
        div{
            float:left;
            margin: 10px;
        }
        div dd{
            margin:0px;
            font-size:10pt;
        }
        div dd.dd_name
        {
            color:blue;
        }
        div dd.dd_city
        {
            color:#000;
        }
    </style>
</head>
<body>
<h2>首页-商品展示</h2>
<hr>
<div style="text-align: center">
    <table width="750" height="60" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td>

                <!-- 商品循环开始 -->
                <%
                    CommodityLogic cdlogic = new CommodityLogic();
                    ArrayList<Commodity> list = cdlogic.getAllItems();
                    if(list!=null&&list.size()>0)
                    {
                        for(int i=0;i<list.size();i++)
                        {
                            Commodity commodity = list.get(i);
                %>
                <div>
                    <dl>
                        <dt>
                            <a href="details.jsp?id=<%=commodity.getId()%>"><img src="images/<%=commodity.getImg()%>" width="120" height="90" border="1"/></a>
                        </dt>
                        <dd class="dd_name"><%=commodity.getName() %></dd>
                        <dd class="dd_city">产地:<%=commodity.getAddress() %>&nbsp;&nbsp;价格:￥ <%=commodity.getPrice() %></dd>
                    </dl>
                </div>
                <!-- 商品循环结束 -->

                <%
                        }
                    }
                %>
            </td>
        </tr>
    </table>
</div>

</body>
</html>
